package cn.yangliu.init.converter;

import java.util.Objects;

import com.alibaba.excel.converters.booleanconverter.BooleanStringConverter;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

/**
 * The type of ascii-jpa.
 * <p>
 * Boolean值转换器 easyexcel提供的只能处理true false
 * 原始数据为T 和 F easyexcel提供的转换器不满足
 *
 * <p>
 * .
 *
 * @author 杨柳
 */
public class BooleanConverter extends BooleanStringConverter {

    @Override
    public Boolean convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
        String stringValue = cellData.getStringValue();
        return Objects.equals(stringValue, "T");
    }

    @Override
    public CellData convertToExcelData(Boolean value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
        return new CellData(value ? "T" : "F");
    }
}
